/**
 * Copyright (C) 2022-2023
 * All rights reserved, Designed By www.tonetn.com
 * 注意：
 * 本软件为www.tonetn.com开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package com.xunyin.modules.goods.service.mapper;

import com.xunyin.common.mapper.CoreMapper;
import com.xunyin.modules.goods.domain.TTeaRoomContainerGoodsLink;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author admin
 * @date 2022-10-28
 */
@Repository
public interface TTeaRoomContainerGoodsLinkMapper extends CoreMapper<TTeaRoomContainerGoodsLink> {

    /**
     * 管理员查询茶室消费商品数量
     * @return
     */
    @Select("select sto.id,sto.*,cgl.stock, sto.pay_money, sto.user_phone,date_format(sto.order_time, '%m-%d %H:%i') as orderTimeStr " +
            " from t_goods_order sto" +
            " left join t_tea_room_container_goods_link cgl on sto.tea_child_id=cgl.tea_room_id AND sto.tea_house_id=cgl.tea_house_id " +
            " where sto.order_status = 1 and order_time >= NOW() - interval 1 day " +
            " and sto.tea_house_id = #{teaHouseId} " +
            "  order by sto.order_time desc ")
    List<TTeaRoomContainerGoodsLink> getGoodsOrderRecordByTeaHouseId(@Param("teaHouseId") Integer teaHouseId);

/*    @Update("update t_tea_room_container_goods_link set stock = IF(stock &lt; 1, 0, stock-1) WHERE id = #{id}");
    int reduceStock(@Param("id") Integer id);*/


}
